package com.authine.cloudpivot.web.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.authine.cloudpivot.web.api.service.MaterialsService;
import com.authine.cloudpivot.web.api.vo.HCOMaterials;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: MaterialsController <br/>
 * Description: <br/>
 * date: 2020/9/4 17:41<br/>
 * @author fj<br />
 * @since JDK 1.8
 */

@Api(description = "和记黄埔相关接口", tags = "讲课材料")
@RestController
@RequestMapping("/public/materials")
@Slf4j
@Validated
public class MaterialsController {
    @Autowired
    private MaterialsService materialsService;

    /**
     * Description: 获取材料编号
     * @Param: [param]
     * @Author: fj
     * @Date: 2020/9/7
     * @Return: com.authine.cloudpivot.web.api.vo.HCOMaterials
     */
    @ApiOperation(value = "获取材料编号")
    @PostMapping("/getHCOMaterials")
    public HCOMaterials getHCOMaterials(@RequestBody JSONObject param) {
        log.info("getHCOMaterials method start，param：{}", param.toJSONString());
        String productKey = param.getString("productKey");
        String materialProperties = param.getString("materialProperties");
        return materialsService.getMaterialNumber(productKey, materialProperties);
    }
}

